#include "StdAfx.h"
#include "Utils.h"

int CAgentUtils::Random(int min, int max)
{
    return ((double)rand() / (RAND_MAX + 1) * (1000*max - 1000*min) + 1000*min) / 1000;
}

void CAgentUtils::Seed()
{
    srand(time(NULL));
}

CSysTime::CSysTime()
{
}

CSysTime::CSysTime(clock_t c)
{
    m_clock = c;
}

CSysTime::~CSysTime()
{
}

CSysTime& CSysTime::operator=(const CSysTime& other)
{
    m_clock = other.m_clock;
    return *this;
}


CSysTime& CSysTime::operator+=(const CSysTime& other)
{
    this->m_clock += other.m_clock;
    return *this;
}

const CSysTime CSysTime::operator+(const CSysTime& other)
{
    return CSysTime(m_clock + other.m_clock);
}

CSysTime& CSysTime::operator-=(const CSysTime& other)
{
    this->m_clock -= other.m_clock;
    return *this;
}

const CSysTime CSysTime::operator-(const CSysTime& other)
{
    return CSysTime(m_clock - other.m_clock);
}

const CSysTime CSysTime::operator/(const CSysTime& other)
{
    return CSysTime(m_clock / other.m_clock);
}

CSysTime CSysTime::Now()
{ 
    return CSysTime(clock()); 
}

CSysTime CSysTime::Span(int s, int ms)
{
    return CSysTime(CLOCKS_PER_SEC * s + (CLOCKS_PER_SEC / 1000) * ms);
}

double CSysTime::GetSeconds()
{
    return (double)m_clock / CLOCKS_PER_SEC;
}